/*!
 * 
 * Angle - Bootstrap Admin App + AngularJS
 * 
 * Version: 3.4
 * Author: @themicon_co
 * Website: http://themicon.co
 * License: https://wrapbootstrap.com/help/licenses
 * 
 */

// APP START
// ----------------------------------- 

(function() {
    'use strict';

    angular
        .module('angle', [
            'app.core',
            'app.routes',
            'app.sidebar',
            'app.navsearch',
            'app.preloader',
            'app.loadingbar',
            'app.translate',
            'app.settings',
            'app.utils',
            'app.studentlist',
            'app.login',
            'app.speclist',
            'app.deptlist',
            'ngCordova'
        ]);
})();
(function() {
    'use strict';

    angular
        .module('app.colors', []);
})();
(function() {
    'use strict';

    angular
        .module('app.core', [
            'ngRoute',
            'ngAnimate',
            'ngStorage',
            'ngCookies',
            'pascalprecht.translate',
            'ui.bootstrap',
            'ui.router',
            'oc.lazyLoad',
            'cfp.loadingBar',
            'ngSanitize',
            'ngResource',
            'ui.utils'
        ]);
})();
(function() {
    'use strict';

    angular
        .module('app.lazyload', []);
})();
(function() {
    'use strict';

    angular
        .module('app.loadingbar', []);
})();
(function() {
    'use strict';

    angular
        .module('app.navsearch', []);
})();
(function() {
    'use strict';

    angular
        .module('app.preloader', []);
})();


(function() {
    'use strict';

    angular
        .module('app.routes', [
            'app.lazyload'
        ]);
})();
(function() {
    'use strict';

    angular
        .module('app.settings', []);
})();
(function() {
    'use strict';

    angular
        .module('app.sidebar', []);
})();
(function() {
    'use strict';

    angular
        .module('app.translate', []);
})();
(function() {
    'use strict';

    angular
        .module('app.utils', [
            'app.colors'
        ]);
})();

(function() {
    'use strict';

    angular
        .module('app.colors')
        .constant('APP_COLORS', {
            'primary': '#5d9cec',
            'success': '#27c24c',
            'info': '#23b7e5',
            'warning': '#ff902b',
            'danger': '#f05050',
            'inverse': '#131e26',
            'green': '#37bc9b',
            'pink': '#f532e5',
            'purple': '#7266ba',
            'dark': '#3a3f51',
            'yellow': '#fad732',
            'gray-darker': '#232735',
            'gray-dark': '#3a3f51',
            'gray': '#dde6e9',
            'gray-light': '#e4eaec',
            'gray-lighter': '#edf1f2'
        });
})();
/**=========================================================
 * Module: colors.js
 * Services to retrieve global colors
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.colors')
        .service('Colors', Colors);

    Colors.$inject = ['APP_COLORS'];

    function Colors(APP_COLORS) {
        this.byName = byName;

        ////////////////

        function byName(name) {
            return (APP_COLORS[name] || '#fff');
        }
    }

})();

(function() {
    'use strict';

    angular
        .module('app.core')
        .config(coreConfig);

    coreConfig.$inject = ['$controllerProvider', '$compileProvider', '$filterProvider', '$provide', '$animateProvider'];

    function coreConfig($controllerProvider, $compileProvider, $filterProvider, $provide, $animateProvider) {

        var core = angular.module('app.core');
        // registering components after bootstrap
        core.controller = $controllerProvider.register;
        core.directive = $compileProvider.directive;
        core.filter = $filterProvider.register;
        core.factory = $provide.factory;
        core.service = $provide.service;
        core.constant = $provide.constant;
        core.value = $provide.value;

        // Disables animation on items with class .ng-no-animation
        $animateProvider.classNameFilter(/^((?!(ng-no-animation)).)*$/);

        // Improve performance disabling debugging features
        // $compileProvider.debugInfoEnabled(false);

    }

})();
/**=========================================================
 * Module: constants.js
 * Define constants to inject across the application
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.core')
        .constant('APP_MEDIAQUERY', {
            'desktopLG': 1200,
            'desktop': 992,
            'tablet': 768,
            'mobile': 480
        });

})();
(function() {
    'use strict';

    angular
        .module('app.core')
        .run(appRun);

    appRun.$inject = ['$rootScope', '$state', '$stateParams', '$window', '$templateCache', 'Colors'];

    function appRun($rootScope, $state, $stateParams, $window, $templateCache, Colors) {

        // Set reference to access them from any scope
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
        $rootScope.$storage = $window.localStorage;

        // Uncomment this to disable template cache
        /*$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
            if (typeof(toState) !== 'undefined'){
              $templateCache.remove(toState.templateUrl);
            }
        });*/

        // Allows to use branding color with interpolation
        // {{ colorByName('primary') }}
        $rootScope.colorByName = Colors.byName;

        // cancel click event easily
        $rootScope.cancel = function($event) {
            $event.stopPropagation();
        };

        // Hooks Example
        // ----------------------------------- 

        // Hook not found
        $rootScope.$on('$stateNotFound',
            function(event, unfoundState /*, fromState, fromParams*/ ) {
                console.log(unfoundState.to); // "lazy.state"
                console.log(unfoundState.toParams); // {a:1, b:2}
                console.log(unfoundState.options); // {inherit:false} + default options
            });
        // Hook error
        $rootScope.$on('$stateChangeError',
            function(event, toState, toParams, fromState, fromParams, error) {
                console.log(error);
            });
        // Hook success
        $rootScope.$on('$stateChangeSuccess',
            function( /*event, toState, toParams, fromState, fromParams*/ ) {
                // display new view from top
                $window.scrollTo(0, 0);
                // Save the route title
                $rootScope.currTitle = $state.current.title;
            });

        // Load a title dynamically
        $rootScope.currTitle = $state.current.title;
        $rootScope.pageTitle = function() {
            var title = $rootScope.app.name + ' - ' + ($rootScope.currTitle || $rootScope.app.description);
            document.title = title;
            return title;
        };

    }

})();


(function() {
    'use strict';

    angular
        .module('app.lazyload')
        .config(lazyloadConfig);

    lazyloadConfig.$inject = ['$ocLazyLoadProvider', 'APP_REQUIRES'];

    function lazyloadConfig($ocLazyLoadProvider, APP_REQUIRES) {

        // Lazy Load modules configuration
        $ocLazyLoadProvider.config({
            debug: false,
            events: true,
            modules: APP_REQUIRES.modules
        });

    }
})();
(function() {
    'use strict';

    angular
        .module('app.lazyload')
        .constant('APP_REQUIRES', {
            // jQuery based and standalone scripts
            scripts: {
                'modernizr': ['vendor/modernizr/modernizr.custom.js'],
                'icons': ['vendor/fontawesome/css/font-awesome.min.css',
                    'vendor/simple-line-icons/css/simple-line-icons.css'
                ],
                'loginmodule': ['logic/login/login.module.js', 'logic/login/login.controller.js'],
                'studentlistmodule': ['logic/student/list.module.js', 'logic/student/list.controller.js', 'logic/student/detail.controller.js'],
                'deptlistmodule': ['logic/department/list.module.js', 'logic/department/list.controller.js'],
                'speclistmodule': ['logic/special/list.module.js', 'logic/special/list.controller.js'],
            },
            // Angular based script (use the right module name)
            modules: [
                //{ name: 'toaster', files: ['vendor/angular-toastr/dist/angular-toastr.min.css', 'vendor/angular-toastr/dist/angular-toastr.min.js','vendor/angular-toastr/dist/angular-toastr.tpls.min.js'] },
                //{name:'loginmodule',files: ['logic/login/login.module.js', 'logic/login/login.controller.js']},
                //  {name:'studentlistmodule',files: [ 'logic/student/list.module.js', 'logic/student/list.controller.js','logic/student/detail.controller.js']},
                //{name:'deptlistmodule',files: [ 'logic/department/list.module.js', 'logic/department/list.controller.js']},
                //{name:'speclistmodule',files: [ 'logic/special/list.module.js', 'logic/special/list.controller.js']},
                //{ name: 'aggrid', files: ['vendor/ag-grid/dist/ag-grid.min.js', 'vendor/ag-grid/dist/styles/ag-grid.css'] },
                //{ name: 'smartgrid', files: ['vendor/angular-smart-table/dist/smart-table.min.js']},
                //{ name: 'nggrid', files: ['vendor/angular-ui-grid/ui-grid.min.css', 'vendor/angular-ui-grid/ui-grid.min.js'] },
                //{ name: 'angulartoast', files: ['vendor/angular-toastr/dist/angular-toastr.min.css', 'vendor/angular-toastr/dist/angular-toastr.min.js','vendor/angular-toastr/dist/angular-toastr.tpls.min.js'] },
                // { name: 'angularpager', files: ['vendor/AngularPager/src/pagination/tm.pagination.js']},
                // { name: 'swal', files: ['vendor/sweetalert2/dist/sweetalert2.min.css','vendor/sweetalert2/dist/sweetalert2.min.js']},
                // { name: 'agchart', files: ['vendor/angular-chart.js/dist/angular-chart.js']},
            ]
        });

})();
(function() {
    'use strict';

    angular
        .module('app.loadingbar')
        .config(loadingbarConfig);
    loadingbarConfig.$inject = ['cfpLoadingBarProvider'];

    function loadingbarConfig(cfpLoadingBarProvider) {
        cfpLoadingBarProvider.includeBar = true;
        cfpLoadingBarProvider.includeSpinner = false;
        cfpLoadingBarProvider.latencyThreshold = 500;
        cfpLoadingBarProvider.parentSelector = '.wrapper > section';
    }
})();
(function() {
    'use strict';

    angular
        .module('app.loadingbar')
        .run(loadingbarRun);
    loadingbarRun.$inject = ['$rootScope', '$timeout', 'cfpLoadingBar'];

    function loadingbarRun($rootScope, $timeout, cfpLoadingBar) {

        // Loading bar transition
        // ----------------------------------- 
        var thBar;
        $rootScope.$on('$stateChangeStart', function() {
            if ($('.wrapper > section').length) // check if bar container exists
                thBar = $timeout(function() {
                cfpLoadingBar.start();
            }, 0); // sets a latency Threshold
        });
        $rootScope.$on('$stateChangeSuccess', function(event) {
            event.targetScope.$watch('$viewContentLoaded', function() {
                $timeout.cancel(thBar);
                cfpLoadingBar.complete();
            });
        });

    }

})();
/**=========================================================
 * Module: navbar-search.js
 * Navbar search toggler * Auto dismiss on ESC key
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.navsearch')
        .directive('searchOpen', searchOpen)
        .directive('searchDismiss', searchDismiss);

    //
    // directives definition
    // 

    function searchOpen() {
        var directive = {
            controller: searchOpenController,
            restrict: 'A'
        };
        return directive;

    }

    function searchDismiss() {
        var directive = {
            controller: searchDismissController,
            restrict: 'A'
        };
        return directive;

    }

    //
    // Contrller definition
    // 

    searchOpenController.$inject = ['$scope', '$element', 'NavSearch'];

    function searchOpenController($scope, $element, NavSearch) {
        $element
            .on('click', function(e) { e.stopPropagation(); })
            .on('click', NavSearch.toggle);
    }

    searchDismissController.$inject = ['$scope', '$element', 'NavSearch'];

    function searchDismissController($scope, $element, NavSearch) {

        var inputSelector = '.navbar-form input[type="text"]';

        $(inputSelector)
            .on('click', function(e) { e.stopPropagation(); })
            .on('keyup', function(e) {
                if (e.keyCode === 27) // ESC
                    NavSearch.dismiss();
            });

        // click anywhere closes the search
        $(document).on('click', NavSearch.dismiss);
        // dismissable options
        $element
            .on('click', function(e) { e.stopPropagation(); })
            .on('click', NavSearch.dismiss);
    }

})();


/**=========================================================
 * Module: nav-search.js
 * Services to share navbar search functions
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.navsearch')
        .service('NavSearch', NavSearch);

    function NavSearch() {
        this.toggle = toggle;
        this.dismiss = dismiss;

        ////////////////

        var navbarFormSelector = 'form.navbar-form';

        function toggle() {
            var navbarForm = $(navbarFormSelector);

            navbarForm.toggleClass('open');

            var isOpen = navbarForm.hasClass('open');

            navbarForm.find('input')[isOpen ? 'focus' : 'blur']();
        }

        function dismiss() {
            $(navbarFormSelector)
                .removeClass('open') // Close control
                .find('input[type="text"]').blur() // remove focus
                // .val('') // Empty input
            ;
        }
    }
})();

(function() {
    'use strict';

    angular
        .module('app.preloader')
        .directive('preloader', preloader);

    preloader.$inject = ['$animate', '$timeout', '$q'];

    function preloader($animate, $timeout, $q) {

        var directive = {
            restrict: 'EAC',
            template: '<div class="preloader-progress">' +
                '<div class="preloader-progress-bar" ' +
                'ng-style="{width: loadCounter + \'%\'}"></div>' +
                '</div>',
            link: link
        };
        return directive;

        ///////

        function link(scope, el) {

            scope.loadCounter = 0;

            var counter = 0,
                timeout;

            // disables scrollbar
            angular.element('body').css('overflow', 'hidden');
            // ensure class is present for styling
            el.addClass('preloader');

            appReady().then(endCounter);

            timeout = $timeout(startCounter);

            ///////

            function startCounter() {

                var remaining = 100 - counter;
                counter = counter + (0.015 * Math.pow(1 - Math.sqrt(remaining), 2));

                scope.loadCounter = parseInt(counter, 10);

                timeout = $timeout(startCounter, 10);
            }

            function endCounter() {

                $timeout.cancel(timeout);

                scope.loadCounter = 100;

                $timeout(function() {
                    // animate preloader hiding
                    $animate.addClass(el, 'preloader-hidden');
                    // retore scrollbar
                    angular.element('body').css('overflow', '');
                }, 300);
            }

            function appReady() {
                var deferred = $q.defer();
                var viewsLoaded = 0;
                // if this doesn't sync with the real app ready
                // a custom event must be used instead
                var off = scope.$on('$viewContentLoaded', function() {
                    viewsLoaded++;
                    // we know there are at least two views to be loaded 
                    // before the app is ready (1-index.html 2-app*.html)
                    if (viewsLoaded === 2) {
                        // with resolve this fires only once
                        $timeout(function() {
                            deferred.resolve();
                        }, 500);

                        off();
                    }

                });

                return deferred.promise;
            }

        } //link
    }

})();
/**=========================================================
 * Module: helpers.js
 * Provides helper functions for routes definition
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.routes')
        .provider('RouteHelpers', RouteHelpersProvider);

    RouteHelpersProvider.$inject = ['APP_REQUIRES'];

    function RouteHelpersProvider(APP_REQUIRES) {

        /* jshint validthis:true */
        return {
            // provider access level
            basepath: basepath,
            resolveFor: resolveFor,
            // controller access level
            $get: function() {
                return {
                    basepath: basepath,
                    resolveFor: resolveFor
                };
            }
        };

        // Set here the base of the relative path
        // for all app views
        function basepath(uri) {
            return 'app/views/' + uri;
        }

        // Generates a resolve object by passing script names
        // previously configured in constant.APP_REQUIRES
        function resolveFor() {
            var _args = arguments;
            return {
                deps: ['$ocLazyLoad', '$q', function($ocLL, $q) {
                    // Creates a promise chain for each argument
                    var promise = $q.when(1); // empty promise
                    for (var i = 0, len = _args.length; i < len; i++) {
                        promise = andThen(_args[i]);
                    }
                    return promise;

                    // creates promise to chain dynamically
                    function andThen(_arg) {
                        // also support a function that returns a promise
                        if (typeof _arg === 'function')
                            return promise.then(_arg);
                        else
                            return promise.then(function() {
                                // if is a module, pass the name. If not, pass the array
                                var whatToLoad = getRequired(_arg);
                                // simple error check
                                if (!whatToLoad) return $.error('Route resolve: Bad resource name [' + _arg + ']');
                                // finally, return a promise
                                return $ocLL.load(whatToLoad);
                            });
                    }
                    // check and returns required data
                    // analyze module items with the form [name: '', files: []]
                    // and also simple array of script files (for not angular js)
                    function getRequired(name) {
                        if (APP_REQUIRES.modules)
                            for (var m in APP_REQUIRES.modules)
                                if (APP_REQUIRES.modules[m].name && APP_REQUIRES.modules[m].name === name)
                                    return APP_REQUIRES.modules[m];
                        return APP_REQUIRES.scripts && APP_REQUIRES.scripts[name];
                    }

                }]
            };
        } // resolveFor

    }


})();


/**=========================================================
 * Module: config.js
 * App routes and resources configuration
 =========================================================*/


(function() {
    'use strict';

    angular
        .module('app.routes')
        .config(routesConfig);

    routesConfig.$inject = ['$stateProvider', '$locationProvider', '$urlRouterProvider', 'RouteHelpersProvider'];

    function routesConfig($stateProvider, $locationProvider, $urlRouterProvider, helper) {

        // Set the following to true to enable the HTML5 Mode
        // You may have to set <base> tag in index and a routing configuration in your server
        $locationProvider.html5Mode(false);

        // defaults to dashboard
        $urlRouterProvider.otherwise('/login');

        // 
        // Application Routes
        // -----------------------------------   
        $stateProvider
            .state('app', {
                url: '/app',
                abstract: true,
                templateUrl: helper.basepath('app.html'),
                resolve: helper.resolveFor('modernizr', 'icons')
            })
            .state('app.studentlist', {
                url: '/studentlist',
                templateUrl: helper.basepath('student/list.html'),
                controller: 'StudentListController',
                //resolve: helper.resolveFor('swal','angularpager','smartgrid', 'studentlistmodule')
            })
            .state('app.deptlist', {
                url: '/deptlist',
                templateUrl: helper.basepath('department/list.html'),
                controller: 'DeptListController',
                //resolve: helper.resolveFor('agchart','swal', 'deptlistmodule')
            })
            .state('app.speclist', {
                url: '/speclist',
                templateUrl: helper.basepath('special/list.html'),
                controller: 'SpecListController',
                //resolve: helper.resolveFor('agchart','swal', 'speclistmodule')
            })
            .state('login', {
                url: '/login',
                title: '登录窗口',
                controller: 'LoginFormController',
                templateUrl: helper.basepath('login.html'),
                //resolve: helper.resolveFor('swal', 'icons', 'loginmodule')
            })
            .state('app.singleview', {
                url: '/singleview',
                title: 'Single View',
                templateUrl: helper.basepath('singleview.html')
            })
            .state('app.submenu', {
                url: '/submenu',
                title: 'Submenu',
                templateUrl: helper.basepath('submenu.html')
            })
            // 
            // CUSTOM RESOLVES
            //   Add your own resolves properties
            //   following this object extend
            //   method
            // ----------------------------------- 
            // .state('app.someroute', {
            //   url: '/some_url',
            //   templateUrl: 'path_to_template.html',
            //   controller: 'someController',
            //   resolve: angular.extend(
            //     helper.resolveFor(), {
            //     // YOUR RESOLVES GO HERE
            //     }
            //   )
            // })
        ;

    } // routesConfig

})();
(function() {
    'use strict';

    angular
        .module('app.settings', [])
        .run(settingsRun);

    settingsRun.$inject = ['$rootScope', '$localStorage'];

    function settingsRun($rootScope, $localStorage) {


        // User Settings
        // -----------------------------------
        $rootScope.user = {
            name: '徐国旭',
            job: '系统开发者',
            picture: 'app/img/user/02.jpg'
        };

        // Hides/show user avatar on sidebar from any element
        $rootScope.toggleUserBlock = function() {
            $rootScope.$broadcast('toggleUserBlock');
        };

        // Global Settings
        // -----------------------------------
        $rootScope.app = {
            name: '大连科技学院新生报到系统',
            description: '本系统由徐国旭开发',
            year: ((new Date()).getFullYear()),
            layout: {
                isFixed: true,
                isCollapsed: false,
                isBoxed: false,
                isRTL: false,
                horizontal: false,
                isFloat: true,
                asideHover: false,
                asideScrollbar: false,
                isCollapsedText: false
            },
            useFullLayout: false,
            hiddenFooter: false,
            offsidebarOpen: false,
            asideToggled: false,
            viewAnimation: 'ng-zoomIn'
        };

        // Setup the layout mode
        $rootScope.app.layout.horizontal = ($rootScope.$stateParams.layout === 'app-a');

        // Restore layout settings [*** UNCOMMENT TO ENABLE ***]
        // if( angular.isDefined($localStorage.layout) )
        //   $rootScope.app.layout = $localStorage.layout;
        // else
        //   $localStorage.layout = $rootScope.app.layout;
        //
        // $rootScope.$watch('app.layout', function () {
        //   $localStorage.layout = $rootScope.app.layout;
        // }, true);

        // Close submenu when sidebar change from collapsed to normal
        $rootScope.$watch('app.layout.isCollapsed', function(newValue) {
            if (newValue === false)
                $rootScope.$broadcast('closeSidebarMenu');
        });

    }

})();
/**=========================================================
 * Module: sidebar-menu.js
 * Handle sidebar collapsible elements
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.sidebar')
        .controller('SidebarController', SidebarController);

    SidebarController.$inject = ['$rootScope', '$scope', '$state', 'SidebarLoader', 'Utils'];

    function SidebarController($rootScope, $scope, $state, SidebarLoader, Utils) {

        activate();

        ////////////////

        function activate() {
            var collapseList = [];

            // demo: when switch from collapse to hover, close all items
            var watchOff1 = $rootScope.$watch('app.layout.asideHover', function(oldVal, newVal) {
                if (newVal === false && oldVal === true) {
                    closeAllBut(-1);
                }
            });


            // Load menu from json file
            // -----------------------------------

            SidebarLoader.getMenu(sidebarReady);

            function sidebarReady(items) {
                $scope.menuItems = items;
            }

            // Handle sidebar and collapse items
            // ----------------------------------

            $scope.getMenuItemPropClasses = function(item) {
                return (item.heading ? 'nav-heading' : '') +
                    (isActive(item) ? ' active' : '');
            };

            $scope.addCollapse = function($index, item) {
                collapseList[$index] = $rootScope.app.layout.asideHover ? true : !isActive(item);
            };

            $scope.isCollapse = function($index) {
                return (collapseList[$index]);
            };

            $scope.toggleCollapse = function($index, isParentItem) {

                // collapsed sidebar doesn't toggle drodopwn
                if (Utils.isSidebarCollapsed() || $rootScope.app.layout.asideHover) return true;

                // make sure the item index exists
                if (angular.isDefined(collapseList[$index])) {
                    if (!$scope.lastEventFromChild) {
                        collapseList[$index] = !collapseList[$index];
                        closeAllBut($index);
                    }
                } else if (isParentItem) {
                    closeAllBut(-1);
                }

                $scope.lastEventFromChild = isChild($index);

                return true;

            };

            // Controller helpers
            // -----------------------------------

            // Check item and children active state
            function isActive(item) {

                if (!item) return;

                if (!item.sref || item.sref === '#') {
                    var foundActive = false;
                    angular.forEach(item.submenu, function(value) {
                        if (isActive(value)) foundActive = true;
                    });
                    return foundActive;
                } else
                    return $state.is(item.sref) || $state.includes(item.sref);
            }

            function closeAllBut(index) {
                index += '';
                for (var i in collapseList) {
                    if (index < 0 || index.indexOf(i) < 0)
                        collapseList[i] = true;
                }
            }

            function isChild($index) {
                /*jshint -W018*/
                return (typeof $index === 'string') && !($index.indexOf('-') < 0);
            }

            $scope.$on('$destroy', function() {
                watchOff1();
            });

        } // activate
    }

})();

/**=========================================================
 * Module: sidebar.js
 * Wraps the sidebar and handles collapsed state
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.sidebar')
        .directive('sidebar', sidebar);

    sidebar.$inject = ['$rootScope', '$timeout', '$window', 'Utils'];

    function sidebar($rootScope, $timeout, $window, Utils) {
        var $win = angular.element($window);
        var directive = {
            // bindToController: true,
            // controller: Controller,
            // controllerAs: 'vm',
            link: link,
            restrict: 'EA',
            template: '<nav class="sidebar" ng-transclude></nav>',
            transclude: true,
            replace: true
                // scope: {}
        };
        return directive;

        function link(scope, element, attrs) {

            var currentState = $rootScope.$state.current.name;
            var $sidebar = element;

            var eventName = Utils.isTouch() ? 'click' : 'mouseenter';
            var subNav = $();

            $sidebar.on(eventName, '.nav > li', function() {

                if (Utils.isSidebarCollapsed() || $rootScope.app.layout.asideHover) {

                    subNav.trigger('mouseleave');
                    subNav = toggleMenuItem($(this), $sidebar);

                    // Used to detect click and touch events outside the sidebar
                    sidebarAddBackdrop();

                }

            });

            var eventOff1 = scope.$on('closeSidebarMenu', function() {
                removeFloatingNav();
            });

            // Normalize state when resize to mobile
            $win.on('resize.sidebar', function() {
                if (!Utils.isMobile())
                    asideToggleOff();
            });

            // Adjustment on route changes
            var eventOff2 = $rootScope.$on('$stateChangeStart', function(event, toState) {
                currentState = toState.name;
                // Hide sidebar automatically on mobile
                asideToggleOff();

                $rootScope.$broadcast('closeSidebarMenu');
            });

            // Autoclose when click outside the sidebar
            if (angular.isDefined(attrs.sidebarAnyclickClose)) {

                var wrapper = $('.wrapper');
                var sbclickEvent = 'click.sidebar';

                var watchOff1 = $rootScope.$watch('app.asideToggled', watchExternalClicks);

            }

            //////

            function watchExternalClicks(newVal) {
                // if sidebar becomes visible
                if (newVal === true) {
                    $timeout(function() { // render after current digest cycle
                        wrapper.on(sbclickEvent, function(e) {
                            // if not child of sidebar
                            if (!$(e.target).parents('.aside').length) {
                                asideToggleOff();
                            }
                        });
                    });
                } else {
                    // dettach event
                    wrapper.off(sbclickEvent);
                }
            }

            function asideToggleOff() {
                $rootScope.app.asideToggled = false;
                if (!scope.$$phase) scope.$apply(); // anti-pattern but sometimes necessary
            }

            scope.$on('$destroy', function() {
                // detach scope events
                eventOff1();
                eventOff2();
                watchOff1();
                // detach dom events
                $sidebar.off(eventName);
                $win.off('resize.sidebar');
                wrapper.off(sbclickEvent);
            });

        }

        ///////

        function sidebarAddBackdrop() {
            var $backdrop = $('<div/>', { 'class': 'dropdown-backdrop' });
            $backdrop.insertAfter('.aside-inner').on('click mouseenter', function() {
                removeFloatingNav();
            });
        }

        // Open the collapse sidebar submenu items when on touch devices
        // - desktop only opens on hover
        function toggleTouchItem($element) {
            $element
                .siblings('li')
                .removeClass('open')
                .end()
                .toggleClass('open');
        }

        // Handles hover to open items under collapsed menu
        // -----------------------------------
        function toggleMenuItem($listItem, $sidebar) {

            removeFloatingNav();

            var ul = $listItem.children('ul');

            if (!ul.length) return $();
            if ($listItem.hasClass('open')) {
                toggleTouchItem($listItem);
                return $();
            }

            var $aside = $('.aside');
            var $asideInner = $('.aside-inner'); // for top offset calculation
            // float aside uses extra padding on aside
            var mar = parseInt($asideInner.css('padding-top'), 0) + parseInt($aside.css('padding-top'), 0);
            var subNav = ul.clone().appendTo($aside);

            toggleTouchItem($listItem);

            var itemTop = ($listItem.position().top + mar) - $sidebar.scrollTop();
            var vwHeight = $win.height();

            subNav
                .addClass('nav-floating')
                .css({
                    position: $rootScope.app.layout.isFixed ? 'fixed' : 'absolute',
                    top: itemTop,
                    bottom: (subNav.outerHeight(true) + itemTop > vwHeight) ? 0 : 'auto'
                });

            subNav.on('mouseleave', function() {
                toggleTouchItem($listItem);
                subNav.remove();
            });

            return subNav;
        }

        function removeFloatingNav() {
            $('.dropdown-backdrop').remove();
            $('.sidebar-subnav.nav-floating').remove();
            $('.sidebar li.open').removeClass('open');
        }
    }


})();


(function() {
    'use strict';

    angular
        .module('app.sidebar')
        .service('SidebarLoader', SidebarLoader);

    SidebarLoader.$inject = ['$http'];

    function SidebarLoader($http) {
        this.getMenu = getMenu;

        ////////////////

        function getMenu(onReady, onError) {
            var menuJson = 'server/sidebar-menu.json',
                menuURL = menuJson + '?v=' + (new Date().getTime()); // jumps cache

            onError = onError || function() { alert('Failure loading menu'); };

            $http
                .get(menuURL)
                .success(onReady)
                .error(onError);
        }
    }
})();
(function() {
    'use strict';

    angular
        .module('app.sidebar')
        .controller('UserBlockController', UserBlockController);

    UserBlockController.$inject = ['$scope'];

    function UserBlockController($scope) {

        activate();

        ////////////////

        function activate() {

            $scope.userBlockVisible = true;

            var detach = $scope.$on('toggleUserBlock', function( /*event, args*/ ) {

                $scope.userBlockVisible = !$scope.userBlockVisible;

            });

            $scope.$on('$destroy', detach);
        }
    }
})();

(function() {
    'use strict';

    angular
        .module('app.translate')
        .config(translateConfig);
    translateConfig.$inject = ['$translateProvider'];

    function translateConfig($translateProvider) {

        $translateProvider.useStaticFilesLoader({
            prefix: 'app/i18n/',
            suffix: '.json'
        });

        $translateProvider.preferredLanguage('cn');
        $translateProvider.useLocalStorage();
        $translateProvider.usePostCompiling(true);
        $translateProvider.useSanitizeValueStrategy('sanitizeParameters');

    }
})();
(function() {
    'use strict';

    angular
        .module('app.translate')
        .run(translateRun);
    translateRun.$inject = ['$rootScope', '$translate'];

    function translateRun($rootScope, $translate) {

        // Internationalization
        // ----------------------

        $rootScope.language = {
            // Handles language dropdown
            listIsOpen: false,
            // list of available languages
            available: {
                'cn': '简体中文'

            },
            // display always the current ui language
            init: function() {
                var proposedLanguage = $translate.proposedLanguage() || $translate.use();
                var preferredLanguage = $translate.preferredLanguage(); // we know we have set a preferred one in app.config
                $rootScope.language.selected = $rootScope.language.available[(proposedLanguage || preferredLanguage)];
            },
            set: function(localeId) {
                // Set the new idiom
                $translate.use(localeId);
                // save a reference for the current language
                $rootScope.language.selected = $rootScope.language.available[localeId];
                // finally toggle dropdown
                $rootScope.language.listIsOpen = !$rootScope.language.listIsOpen;
            }
        };

        $rootScope.language.init();

    }
})();
/**=========================================================
 * Module: animate-enabled.js
 * Enable or disables ngAnimate for element with directive
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('animateEnabled', animateEnabled);

    animateEnabled.$inject = ['$animate'];

    function animateEnabled($animate) {
        var directive = {
            link: link,
            restrict: 'A'
        };
        return directive;

        function link(scope, element, attrs) {
            scope.$watch(function() {
                return scope.$eval(attrs.animateEnabled, scope);
            }, function(newValue) {
                $animate.enabled(!!newValue, element);
            });
        }
    }

})();

/**=========================================================
 * Module: browser.js
 * Browser detection
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .service('Browser', Browser);

    Browser.$inject = ['$window'];

    function Browser($window) {
        return $window.jQBrowser;
    }

})();

/**=========================================================
 * Module: clear-storage.js
 * Removes a key from the browser storage via element click
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('resetKey', resetKey);

    resetKey.$inject = ['$state', '$localStorage'];

    function resetKey($state, $localStorage) {
        var directive = {
            link: link,
            restrict: 'A',
            scope: {
                resetKey: '@'
            }
        };
        return directive;

        function link(scope, element) {
            element.on('click', function(e) {
                e.preventDefault();

                if (scope.resetKey) {
                    delete $localStorage[scope.resetKey];
                    $state.go($state.current, {}, { reload: true });
                } else {
                    $.error('No storage key specified for reset.');
                }
            });
        }
    }

})();

/**=========================================================
 * Module: fullscreen.js
 * Toggle the fullscreen mode on/off
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('toggleFullscreen', toggleFullscreen);

    toggleFullscreen.$inject = ['Browser'];

    function toggleFullscreen(Browser) {
        var directive = {
            link: link,
            restrict: 'A'
        };
        return directive;

        function link(scope, element) {
            // Not supported under IE
            if (Browser.msie) {
                element.addClass('hide');
            } else {
                element.on('click', function(e) {
                    e.preventDefault();

                    if (screenfull.enabled) {

                        screenfull.toggle();

                        // Switch icon indicator
                        if (screenfull.isFullscreen)
                            $(this).children('em').removeClass('fa-expand').addClass('fa-compress');
                        else
                            $(this).children('em').removeClass('fa-compress').addClass('fa-expand');

                    } else {
                        $.error('Fullscreen not enabled');
                    }

                });
            }
        }
    }


})();

/**=========================================================
 * Module: load-css.js
 * Request and load into the current page a css file
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('loadCss', loadCss);

    function loadCss() {
        var directive = {
            link: link,
            restrict: 'A'
        };
        return directive;

        function link(scope, element, attrs) {
            element.on('click', function(e) {
                if (element.is('a')) e.preventDefault();
                var uri = attrs.loadCss,
                    link;

                if (uri) {
                    link = createLink(uri);
                    if (!link) {
                        $.error('Error creating stylesheet link element.');
                    }
                } else {
                    $.error('No stylesheet location defined.');
                }

            });
        }

        function createLink(uri) {
            var linkId = 'autoloaded-stylesheet',
                oldLink = $('#' + linkId).attr('id', linkId + '-old');

            $('head').append($('<link/>').attr({
                'id': linkId,
                'rel': 'stylesheet',
                'href': uri
            }));

            if (oldLink.length) {
                oldLink.remove();
            }

            return $('#' + linkId);
        }
    }

})();

/**=========================================================
 * Module: now.js
 * Provides a simple way to display the current time formatted
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('now', now);

    now.$inject = ['dateFilter', '$interval'];

    function now(dateFilter, $interval) {
        var directive = {
            link: link,
            restrict: 'EA'
        };
        return directive;

        function link(scope, element, attrs) {
            var format = attrs.format;

            function updateTime() {
                var dt = dateFilter(new Date(), format);
                element.text(dt);
            }

            updateTime();
            var intervalPromise = $interval(updateTime, 1000);

            scope.$on('$destroy', function() {
                $interval.cancel(intervalPromise);
            });

        }
    }

})();

/**=========================================================
 * Module: table-checkall.js
 * Tables check all checkbox
 =========================================================*/
(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('checkAll', checkAll);

    function checkAll() {
        var directive = {
            link: link,
            restrict: 'A'
        };
        return directive;

        function link(scope, element) {
            element.on('change', function() {
                var $this = $(this),
                    index = $this.index() + 1,
                    checkbox = $this.find('input[type="checkbox"]'),
                    table = $this.parents('table');
                // Make sure to affect only the correct checkbox column
                table.find('tbody > tr > td:nth-child(' + index + ') input[type="checkbox"]')
                    .prop('checked', checkbox[0].checked);

            });
        }
    }

})();

/**=========================================================
 * Module: trigger-resize.js
 * Triggers a window resize event from any element
 =========================================================*/
(function() {
    'use strict';

    angular
        .module('app.utils')
        .directive('triggerResize', triggerResize);

    triggerResize.$inject = ['$window', '$timeout'];

    function triggerResize($window, $timeout) {
        var directive = {
            link: link,
            restrict: 'A'
        };
        return directive;

        function link(scope, element, attributes) {
            element.on('click', function() {
                $timeout(function() {
                    // all IE friendly dispatchEvent
                    var evt = document.createEvent('UIEvents');
                    evt.initUIEvent('resize', true, false, $window, 0);
                    $window.dispatchEvent(evt);
                    // modern dispatchEvent way
                    // $window.dispatchEvent(new Event('resize'));
                }, attributes.triggerResize || 300);
            });
        }
    }

})();

/**=========================================================
 * Module: utils.js
 * Utility library to use across the theme
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.utils')
        .service('Utils', Utils);

    Utils.$inject = ['$window', 'APP_MEDIAQUERY'];

    function Utils($window, APP_MEDIAQUERY) {

        var $html = angular.element('html'),
            $win = angular.element($window),
            $body = angular.element('body');

        return {
            // DETECTION
            support: {
                transition: (function() {
                    var transitionEnd = (function() {

                        var element = document.body || document.documentElement,
                            transEndEventNames = {
                                WebkitTransition: 'webkitTransitionEnd',
                                MozTransition: 'transitionend',
                                OTransition: 'oTransitionEnd otransitionend',
                                transition: 'transitionend'
                            },
                            name;

                        for (name in transEndEventNames) {
                            if (element.style[name] !== undefined) return transEndEventNames[name];
                        }
                    }());

                    return transitionEnd && { end: transitionEnd };
                })(),
                animation: (function() {

                    var animationEnd = (function() {

                        var element = document.body || document.documentElement,
                            animEndEventNames = {
                                WebkitAnimation: 'webkitAnimationEnd',
                                MozAnimation: 'animationend',
                                OAnimation: 'oAnimationEnd oanimationend',
                                animation: 'animationend'
                            },
                            name;

                        for (name in animEndEventNames) {
                            if (element.style[name] !== undefined) return animEndEventNames[name];
                        }
                    }());

                    return animationEnd && { end: animationEnd };
                })(),
                requestAnimationFrame: window.requestAnimationFrame ||
                    window.webkitRequestAnimationFrame ||
                    window.mozRequestAnimationFrame ||
                    window.msRequestAnimationFrame ||
                    window.oRequestAnimationFrame ||
                    function(callback) { window.setTimeout(callback, 1000 / 60); },
                /*jshint -W069*/
                touch: (
                    ('ontouchstart' in window && navigator.userAgent.toLowerCase().match(/mobile|tablet/)) ||
                    (window.DocumentTouch && document instanceof window.DocumentTouch) ||
                    (window.navigator['msPointerEnabled'] && window.navigator['msMaxTouchPoints'] > 0) || //IE 10
                    (window.navigator['pointerEnabled'] && window.navigator['maxTouchPoints'] > 0) || //IE >=11
                    false
                ),
                mutationobserver: (window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver || null)
            },
            // UTILITIES
            isInView: function(element, options) {
                /*jshint -W106*/
                var $element = $(element);

                if (!$element.is(':visible')) {
                    return false;
                }

                var window_left = $win.scrollLeft(),
                    window_top = $win.scrollTop(),
                    offset = $element.offset(),
                    left = offset.left,
                    top = offset.top;

                options = $.extend({ topoffset: 0, leftoffset: 0 }, options);

                if (top + $element.height() >= window_top && top - options.topoffset <= window_top + $win.height() &&
                    left + $element.width() >= window_left && left - options.leftoffset <= window_left + $win.width()) {
                    return true;
                } else {
                    return false;
                }
            },

            langdirection: $html.attr('dir') === 'rtl' ? 'right' : 'left',

            isTouch: function() {
                return $html.hasClass('touch');
            },

            isSidebarCollapsed: function() {
                return $body.hasClass('aside-collapsed') || $body.hasClass('aside-collapsed-text');
            },

            isSidebarToggled: function() {
                return $body.hasClass('aside-toggled');
            },

            isMobile: function() {
                return $win.width() < APP_MEDIAQUERY.tablet;
            }

        };
    }
})();

(function() {
    'use strict';

    angular
        .module('app.deptlist', []);
})();


/**
 * Created by HiWin10 on 2016/7/27.
 */
(function() {
    'use strict';
    angular
        .module('app.login', []);
})();


(function() {
    'use strict';

    angular
        .module('app.speclist', []);
})();


(function() {
    'use strict';

    angular
        .module('app.studentlist', []);
})();


/**
 * Created by HiWin10 on 2016/8/4.
 */
(function() {
    'use strict';

    var m = angular
        .module('app.deptlist', ['getdatamodule', 'chart.js']);
    m.controller('DeptListController', DeptListController);
    m.config(['ChartJsProvider', function(ChartJsProvider) {
        // Configure all charts

        ChartJsProvider.setOptions({

            colors: ['#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'],

            title: {
                display: true,
                text: '学院报道情况',
                fullWidth: true,
                fontSize: 24,
                fontColor: "#666",
                fontStyle: 'bold'

            },
            legend: {
                display: true,
                labels: {
                    fontColor: 'rgb(255, 99, 132)'
                }
            }

        });
    }])
    DeptListController.$inject = ['$scope', 'getdataservice', '$timeout'];

    function DeptListController($scope, getdataservice, $timeout) {
        $scope.getexcel = baseurl + "/Excel/GetDeptExcel";
        $scope.isLoading = false;
        $scope.getdept = function() {
            $scope.isLoading = true
            $scope.havenums = 0;
            $scope.regnums = 0;

            var label = [];
            var data1 = [];
            var data2 = [];

            getdataservice.all('/department/index/v=' + new Date().getTime()).then(function(data) {
                var label = [];
                var data1 = [];
                var data2 = [];
                $scope.collections = data.Data;

                angular.forEach(data.Data, function(dataa) {
                    label.push(dataa.Dept_name);
                    data1.push(dataa.Dept_havenum);
                    data2.push(dataa.Dept_regnum);
                    $scope.havenums += dataa.Dept_havenum;
                    $scope.regnums += dataa.Dept_regnum;
                });

                $scope.labels = label;
                $scope.type = 'StackedBar';
                $scope.series = ['实报', '应报'];
                $scope.data = [
                    data1,
                    data2
                ];
                $scope.colors = ['#ff6384', '#00ADF9'];

                $scope.isLoading = false;
            }, function() {
                $scope.isLoading = false;
            });
        };
        setInterval(function() {
            $scope.getdept();
        }, 30000);

    }
})();


/**=========================================================
 * Module: access-login.js
 * Demo for login api
 =========================================================*/

(function() {
    'use strict';

    angular
        .module('app.login', ['getdatamodule'])
        .controller('LoginFormController', LoginFormController)

    ;

    LoginFormController.$inject = ['$http', '$state', '$scope', 'getdataservice', 'cfpLoadingBar'];

    function LoginFormController($http, $state, $scope, getdataservice, cfpLoadingBar) {
        var vm = this;
        $scope.Animation = 'ng-fadeInRight';
        activate();
        ////////////////
        function activate() {
            getcaptcha();
            $scope.userpassword = "";
            $scope.username = "";
            $scope.captchacode = "";
            // bind here all data from the form
            function getcaptcha() {
                $scope.captchaurl = baseurl + '/User/CaptchaImage?id=' + new Date().getTime();
            };
            // place the message if something goes wrong
            $scope.authMsg = "";
            $scope.getcaptchacode = function() { getcaptcha(); }
            vm.login = function() {
                $scope.authMsg = "";

                if (vm.loginForm.$valid) {

                    $scope.disable = true;
                    cfpLoadingBar.start();
                    var p = getdataservice.all('/User/Auth/?username=' + $scope.username + '&password=' + $scope.userpassword)
                    p.then(function(data) {

                        if (data.ResultCode == 100 || data.ResultCode == 500) {
                            swal('错误!', data.Memo, 'error');
                            $scope.authMsg = data.Memo;
                            getcaptcha();
                        } else
                        if (data.ResultCode == 200 && data.Data.User_id > 0) {
                            $state.go("app.singleview");
                        }
                        $scope.disable = false;

                    }, function() {
                        $scope.disable = false;
                        $scope.authMsg = "连接服务器出错，请联系管理员！"
                    });


                } else {
                    // set as dirty if the user click directly to login so we show the validation messages
                    /*jshint -W106*/
                    vm.loginForm.userpassword.$dirty = true;
                    vm.loginForm.username.$dirty = true;
                    vm.loginForm.captchacode.$dirty = true;
                }
            };
        }
    }
})();

/**
 * Created by HiWin10 on 2016/7/30.
 */
//var baseurl = "http://localhost:62030";//连接远程服务器的设置
var baseurl = "http://125.222.146.11:8181"; //连接远程服务器的设置
(function() {
    'use strict';

    var m = angular
        .module('getdatamodule', ['chieffancypants.loadingBar', 'ngAnimate']);

    m.config(['$provide', function($provide) {

        $provide.service('getdataservice', ['$http', '$q', '$filter', 'cfpLoadingBar', function($http, $q, $filter, cfpLoadingBar) {
            return {
                all: function(url) {
                    var deferred = $q.defer();
                    var promise = deferred.promise;
                    cfpLoadingBar.start();
                    $http({
                            method: 'POST',
                            url: baseurl + url,
                            headers: {
                                'Content-Type': 'application/x-www-form-urlencoded'
                            }
                        })
                        .then(
                            function(data) {
                                deferred.resolve(data.data);
                                cfpLoadingBar.complete();

                            },
                            function(data) {

                                swal({
                                    title: '出现错误!',
                                    text: '连接服务器出错，请联系管理员！',
                                    type: 'error',
                                    confirmButtonText: '好吧'

                                });
                                deferred.reject(data);
                                cfpLoadingBar.complete();
                            }
                        )

                    /*
                    .success(function(data){
                        deferred.resolve(data.data);
                    })
                    .error(function (data,status,hedaers,config) {

                        console.log(status);
                        deferred.reject(data);
                    });
                    */
                    return promise;
                },
                getpate: function getPage(start, number, params, objs) {

                    var deferred = $q.defer();

                    var filtered = params.search.predicateObject ? $filter('filter')(objs, params.search.predicateObject) : objs;

                    if (params.sort.predicate) {
                        filtered = $filter('orderBy')(filtered, params.sort.predicate, params.sort.reverse);
                    }

                    var result = filtered.slice(start, start + number);


                    //note, the server passes the information about the data set size
                    deferred.resolve({
                        data: result,
                        totalItems: filtered.length,
                        numberOfPages: Math.ceil(filtered.length / number),
                        filtereddata: [].concat(filtered)
                    })


                    return deferred.promise;
                }


            }
        }]);
    }])

})();
/**
 * Created by HiWin10 on 2016/8/4.
 */

(function() {
    'use strict';

    var m = angular
        .module('app.speclist', ['getdatamodule', 'chart.js']);
    m.controller('SpecListController', SpecListController);
    m.config(['ChartJsProvider', function(ChartJsProvider) {
        // Configure all charts
        ChartJsProvider.setOptions({
            colors: ['#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'],
            responsive: true,
            scale: {

            },

            title: {
                display: true,
                text: '专业报道情况',
                fullWidth: true,
                fontSize: 24,
                fontColor: "#666",
                fontStyle: 'bold'

            },
            legend: {
                display: true,
                labels: {
                    fontColor: 'rgb(255, 99, 132)',
                    position: 'bottom'
                }
            }

        });
    }])
    SpecListController.$inject = ['$scope', 'getdataservice', '$filter'];

    function SpecListController($scope, getdataservice, $filter) {
        $scope.getexcel = baseurl + "/Excel/GetSpeExcel";
        $scope.table = true;
        $scope.isLoading = false;
        var collections = [];
        $scope.filterdept = "";
        $scope.filtername = "";
        $scope.search = function() {
            $scope.data = [
                [],
                []
            ];
            var label = [];
            var data1 = [];
            var data2 = [];
            if (collections.length <= 0) { return; }

            if ($scope.filtername == "" && $scope.filterdept == "") {
                $scope.getdept();
                return;
            }
            var cc = $filter('filter')(collections, { 'Spe_name': $scope.filtername });
            $scope.collections = $filter('filter')(cc, { 'Dept_name': $scope.filterdept })
            angular.forEach($scope.collections, function(data) {
                label.push(data.Spe_name);
                data1.push(data.Spec_havenum);
                data2.push(data.Spec_regnum);
            });
            $scope.labels = label;
            $scope.data = [
                data1,
                data2
            ];
            console.log(label);
            console.log(data1, data2);
            console.log($scope.data);
        }
        $scope.getdept = function() {
            $scope.data = [
                [],
                []
            ];
            $scope.filtername = "";
            $scope.isLoading = true
            getdataservice.all('/Special/Index/v=' + new Date().getTime()).then(function(data) {
                var label = [];
                var data1 = [];
                var data2 = [];
                collections = data.Data;
                $scope.collections = collections;

                $scope.isLoading = false;
                angular.forEach($scope.collections, function(data) {
                    label.push(data.Spe_name);
                    data1.push(data.Spec_havenum);
                    data2.push(data.Spec_regnum);
                });

                $scope.labels = label;

                $scope.series = ['实报', '应报'];


                $scope.data = [
                    data1,
                    data2
                ];
                $scope.colors = ['#ff6384', '#00ADF9'];

            }, function() {
                $scope.isLoading = false;
            })
        }


    }
})();
(function() {
    'use strict';

    function count(o) {
        var t = typeof o;
        if (t == 'string') {
            return o.length;
        } else if (t == 'object') {
            var n = 0;
            for (var i in o) {
                n++;
            }
            return n;
        }
        return false;
    };
    angular
        .module('app.studentlist', ['getdatamodule', 'tm.pagination', 'ui.bootstrap'])
        .filter('unique', function() {
            return function(arr, field) {

                var o = {},
                    i, l = count(arr),
                    r = [];
                for (i = 0; i < l; i += 1) {
                    o[arr[i][field]] = arr[i];
                }
                for (i in o) {
                    r.push(o[i]);
                }
                return r;
            };
        })

    .controller("StudentListController", StudentListController)

    ;
    StudentListController.$inject = ['$state', '$scope', 'getdataservice', '$uibModal','$cordovaBarcodeScanner'];

    function StudentListController($state, $scope, getdataservice, $uibModal,$cordovaBarcodeScanner) {

        var studentfiler = "";
        var students = [];
        var filerdata = [];
        getdataservice.all("/student/getshengfen/?id=" + new Date().getTime()).then(function(data) {
            $scope.studentshengfen = data.Data;
            $scope.isLoading = false;
        }, function(data) {
            $scope.isLoading = false;
        });
        getdataservice.all("/special/index/?id=" + new Date().getTime()).then(function(data) {
            $scope.zhuanyelist = data.Data;
            $scope.Spe_ID = $scope.zhuanyelist[0].Spe_id;
            $scope.isLoading = false;
        }, function(data) {
            $scope.isLoading = false;
        });
        $scope.url = baseurl + "/Excel/GetStudentsExcel/";
        $scope.Student_id = "";
        $scope.Student_name = "";
        $scope.Student_shengfen = "";
        $scope.Student_isbd = "";
        $scope.Student_tzsh = "";
        $scope.paginationConf = {
            currentPage: 1,
            totalItems: 0,
            itemsPerPage: 10,
            pagesLength: 5,
            perPageOptions: [10, 20, 30, 40, 50],
            onChange: function() {
                $scope.studentdisplay = [].concat(filerdata).slice(($scope.paginationConf.currentPage - 1) * $scope.paginationConf.itemsPerPage, $scope.paginationConf.currentPage * $scope.paginationConf.itemsPerPage);
            }
        };

        $scope.scanBarcode = function() {


            $cordovaBarcodeScanner.scan().then(function(imageData) {
                if (imageData.text == undefined || imageData.text.length == 0) {
                    swal("扫描出错或者扫描取消！", "错误！", "error");
                    return;
                }
                $scope.isLoading = true;
                studentfiler = "&tid=&tname=&speid=&ttzsh=" + imageData.text + "&tshengfen=&tisbd=";
                getdataservice.all("/Student/GetStudents/?id=" + new Date().getTime() + "&p=" + $scope.paginationConf.currentPage + "&psize=" + $scope.paginationConf.itemsPerPage + studentfiler).then(function(data) {
                    if (data.Data != null && data.Data.length > 0) {
                        $scope.studentlist = data.Data;
                        students = $scope.studentlist;
                        $scope.isLoading = false;
                        $scope.studentdisplay = [].concat(students).slice(0, $scope.paginationConf.itemsPerPage);
                        filerdata = students;
                        $scope.paginationConf.totalItems = filerdata.length;
                        $scope.ShowDetail($scope.studentlist[0].Student_id);

                        return $scope.studentlist;
                    } else {
                        swal("二维码不正确！", "错误！", "error");
                        return
                    }

                }, function(data) {
                    $scope.isLoading = false;
                });
            }, function(error) {
                swal("扫描出错！错误代码:" + error, "错误！", "error");
                console.log("An error happened -> " + error);
            });


        };
        $scope.resetall = function() {
            $scope.Student_id = "";
            $scope.Student_name = "";
            $scope.Student_shengfen = "";
            $scope.Student_isbd = "";
            $scope.Student_tzsh = "";
            $scope.Spe_ID = $scope.zhuanyelist[0].Spe_id;
        }
        $scope.callserver = function(tablestate) {
            //console.log(tablestate);
            getdataservice.getpate(0, $scope.paginationConf.itemsPerPage, tablestate, students).then(function(result) {

                $scope.totalnums = result.totalItems;
                $scope.page = result.numberOfPages;
                filerdata = result.filtereddata;
                $scope.paginationConf.totalItems = filerdata.length;
                $scope.studentdisplay = [].concat(filerdata).slice(($scope.paginationConf.currentPage - 1) * $scope.paginationConf.itemsPerPage, $scope.paginationConf.currentPage * $scope.paginationConf.itemsPerPage);
                //pagination.totalItemCount = result.totalItems;
                //pagination.maxSize = pagination.totalItemCount/pagination.number;
            })
        };
        $scope.getStudent = function() {
            console.log($scope.Student_id);
            console.log($scope.Student_name);
            console.log($scope.Spe_ID);
            console.log($scope.Student_tzsh);
            console.log($scope.Student_shengfen);
            console.log($scope.Student_isbd);
            $scope.isLoading = true;
            studentfiler = "&tid=" + $scope.Student_id + "&tname=" + $scope.Student_name + "&speid=" + $scope.Spe_ID + "&ttzsh=" + $scope.Student_tzsh + "&tshengfen=" + $scope.Student_shengfen + "&tisbd=" + $scope.Student_isbd;
            getdataservice.all("/Student/GetStudents/?id=" + new Date().getTime() + "&p=" + $scope.paginationConf.currentPage + "&psize=" + $scope.paginationConf.itemsPerPage + studentfiler).then(function(data) {
                $scope.studentlist = data.Data;
                students = $scope.studentlist;
                $scope.isLoading = false;
                $scope.studentdisplay = [].concat(students).slice(0, $scope.paginationConf.itemsPerPage);
                filerdata = students;
                $scope.paginationConf.totalItems = filerdata.length;
                return $scope.studentlist;
            }, function(data) {
                $scope.isLoading = false;
            });
        };

        $scope.ShowDetail = function(stuid) {
            getdataservice.all("/Student/Details/" + stuid + "/?id=" + new Date().getTime()).then(
                function(data) {
                    if (data.Data.length <= 0) {
                        swal("参数错误，没有该生数据", "错误！", "error");
                        return;
                    }

                    $uibModal.open({
                        animation: true,
                        backdrop: true,
                        keyboard: true,
                        templateUrl: 'app/views/student/detail.html',
                        controller: 'StudentDetailCtrl',
                        size: 'md',
                        resolve: {
                            studentdetail: function() {
                                return data.Data;
                            },

                        },

                    });

                },
                function(data) {

                }
            )

        }

    }

    angular
        .module('app.studentlist').controller('StudentDetailCtrl', StudentDetailCtrl);
    StudentDetailCtrl.$inject = ['$scope', 'studentdetail', 'getdataservice', '$uibModalInstance'];

    function StudentDetailCtrl($scope, studentdetail, getdataservice, $uibModalInstance) {
        studentdetail.Student_isbd == 1 ? $scope.baodao = true : $scope.baodao = false;
        $scope.studentdetail = studentdetail;
        $scope.getexcel = baseurl + "/Excel/GetStudentsExcel/" + studentdetail.Spe_id;

        $scope.CancelBaodao = function(id) {
            swal({
                title: '确认报道取消吗',
                html: '确认通知书号为:<span class="text-bold text-danger">' + studentdetail.Student_tzsh + '</span>、姓名为:<span class="text-bold text-danger">' + studentdetail.Student_name + '</span>取消报到吗？',
                type: 'error',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                allowOutsideClick: true,
                allowEscapeKey: true
            }).then(function(isConfirm) {
                if (isConfirm == true) {
                    getdataservice.all("/student/cancelbaodao/" + studentdetail.Student_id + "/?v=" + new Date().getTime()).then(
                        function(data) {
                            if (data.ResultCode != 200) {
                                swal({
                                    title: '出错！',
                                    text: data.Memo,
                                    type: 'error',
                                    allowOutsideClick: false,
                                    allowEscapeKey: false
                                })
                            } else {

                                swal({
                                    title: '恭喜！',
                                    text: '该生取消报道成功',
                                    type: 'success',
                                    allowOutsideClick: false,
                                    allowEscapeKey: false
                                });
                                getdataservice.all("/Student/Details/" + studentdetail.Student_id + "/?id=" + new Date().getTime()).then(
                                    function(data) {
                                        if (data.ResultCode != 200) {
                                            swal({
                                                title: '出错！',
                                                text: data.Memo,
                                                type: 'error',
                                                allowOutsideClick: false,
                                                allowEscapeKey: false
                                            })
                                        } else {
                                            data.Data.Student_isbd == 1 ? $scope.baodao = true : $scope.baodao = false;
                                            $scope.studentdetail = data.Data;

                                        }
                                    }
                                )



                            }

                        }
                    )
                }
            })

        }
        $scope.close = function() {
            $uibModalInstance.dismiss('close');
            return
        }
        $scope.ConfirmBaodao = function(id) {
            swal({
                title: '确认吗',
                html: '确认通知书号为:<span class="text-bold text-danger">' + studentdetail.Student_tzsh + '</span>、姓名为:<span class="text-bold text-danger">' + studentdetail.Student_name + '</span>报到吗？',
                type: 'question',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                allowOutsideClick: false,
                allowEscapeKey: false
            }).then(function(isConfirm) {
                if (isConfirm == true) {
                    getdataservice.all("/student/confirmbaodao/" + studentdetail.Student_id + "/?v=" + new Date().getTime()).then(
                        function(data) {
                            if (data.ResultCode != 200) {
                                swal({
                                    title: '出错！',
                                    text: data.Memo,
                                    type: 'error',
                                    allowOutsideClick: false,
                                    allowEscapeKey: false
                                })
                            } else {

                                swal({
                                    title: '恭喜！',
                                    text: '该生报道成功',
                                    type: 'success',
                                    allowOutsideClick: false,
                                    allowEscapeKey: false
                                });
                                getdataservice.all("/Student/Details/" + studentdetail.Student_id + "/?id=" + new Date().getTime()).then(
                                    function(data) {
                                        if (data.ResultCode != 200) {
                                            swal({
                                                title: '出错！',
                                                text: data.Memo,
                                                type: 'error',
                                                allowOutsideClick: false,
                                                allowEscapeKey: false
                                            })
                                        } else {
                                            data.Data.Student_isbd == 1 ? $scope.baodao = true : $scope.baodao = false;
                                            $scope.studentdetail = data.Data;
                                        }
                                    }
                                )



                            }

                        }
                    )
                }
            })

        }
    }
})();